﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain;
using ConsoleClient.Services;

namespace ConsoleClient
{
    class Program
    {
        static void Main(string[] args)
        {
            SchoolService svc = new SchoolService();

            IList<Department> departments = svc.GetDepartments();

            Person Fadi = svc.GetPerson(4, false, false);

            Console.WriteLine(String.Format("Working on {0} {1}, Hired at {2:D}",
                Fadi.FirstName, Fadi.LastName, Fadi.HireDate));
            Console.WriteLine();

            Console.WriteLine("The ID is not generated by the database in this instance, so please give me a number that is not used already");
            int id = Int32.Parse(Console.ReadLine());

            Console.WriteLine("I can bug you for a title as well, can't I?");
            string title = Console.ReadLine();

            Course newCourse = new Course { CourseID = id, Credits = 10, Days = "MT", Time = DateTime.Now, Title = title };
            newCourse.Persons = new List<Person> { Fadi }; // normally, your object ctor would have done this
            newCourse.Enrollments = new List<Enrollment>();
            newCourse.Department = departments.First();
            newCourse.Department.Courses.Add(newCourse);

            Fadi.FirstName = "Fadi,Changed at " + DateTime.Now.ToShortTimeString();


            Fadi.Courses.Add(newCourse);


            svc.SavePerson(Fadi);

            Console.WriteLine("Finished, go check your database. I added the new course to department:" + newCourse.Department.Name);
            Console.ReadLine();


        }
    }
}
